package com.dkm.ec.relation.domain;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.dkm.biz.domain.AbstractDomain;
import com.dkm.base.api.constants.Bool;
import com.dkm.base.core.helper.SpringHelper;
import com.dkm.ec.relation.persistence.dao.RelationGroupDao;
import com.dkm.ec.relation.persistence.entity.RelationGroupPo;
import com.dkm.ec.relation.persistence.entity.RelationGroupStatus;
import com.dkm.ec.relation.repository.RelationGroupRepository;

/**
 * 对象功能:t_relation_group 领域对象实体
 * 开发公司:dkm.com
 * 开发人员:ZHH
 * 创建时间:2017-07-21 16:58:21
 */
@SuppressWarnings("serial")
@Service
@Scope("prototype")
public class RelationGroup extends AbstractDomain<String, RelationGroupPo>{
	
	@Resource
	private RelationGroupRepository relationGroupRepository;
	
	@Resource
 	 private RelationGroupDao relationGroupDao = null;

	protected void init(){
		relationGroupDao = SpringHelper.getBean(RelationGroupDao.class);
		setDao(relationGroupDao);
	}

	public void createGroupById(String userId) {
		for(RelationGroupStatus  relationGroupStatus : RelationGroupStatus.values()){
			RelationGroupPo relationGroupPo = new RelationGroupPo();
			relationGroupPo.setPartyId(userId);
			relationGroupPo.setIsDefault(Bool.Y.toString());
			relationGroupPo.setName("全部");
			relationGroupPo.setType(relationGroupStatus.toString());
			relationGroupPo.setCreateTime(new Date());
			
			RelationGroup relationGroup = relationGroupRepository.newInstance(relationGroupPo);
			 relationGroup.create();
 		}
	}	 
	 
}
